package ar.dvorakes.generator;

import java.util.HashMap;
import java.util.Map;

public class GUIBINKeyboard {

	private String name = "";

	private Map<String, Map<String, GUIBINKey>> rows = new HashMap<String, Map<String, GUIBINKey>>();

	public GUIBINKeyboard(String name, Map<String, Map<String, GUIBINKey>> rows) {
		this.name = name;
		this.rows = rows;
	}

	public String getName(String name) {
		return this.name;
	}

	public GUIBINKey getKey(String id) {
		String[] processedKey = processKey(id);
		Map<String, GUIBINKey> row = rows.get(processedKey[1]);
		return row.get(id);
	}

	private String[] processKey(String key) {
		String[] ret = new String[3];
		ret[0] = key.substring(0, 2);
		ret[1] = key.substring(2, 3);
		ret[2] = key.substring(3, 4);
		return ret;
	}
}
